--
-- Created by IntelliJ IDEA.
-- User: Administrator
-- Date: 2018/3/26
-- Time: 18:03
-- To change this template use File | Settings | File Templates.
-- https://github.com/pintsized/lua-resty-http


local http = require "resty.http"
local httpc = http.new()
local res, err = httpc:request_uri("http://example.com/helloworld", {
    method = "GET",
    body = "a=1&b=2",
    headers = {
        ["Content-Type"] = "application/x-www-form-urlencoded",
    }
})

if not res then
    ngx.say("failed to request: ", err)
    return
end

-- In this simple form, there is no manual connection step, so the body is read
-- all in one go, including any trailers, and the connection closed or keptalive
-- for you.

ngx.status = res.status

for k,v in pairs(res.headers) do

    ngx.log(ngx.ERR,"k:", k, "v:",v)
end

ngx.say(res.body)

